package cn.data.test;

import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;

import cn.datawin.task.Task;
import cn.datawin.task.dao.DbUtil;

public class MainEntryrule {
	
	public static void main(String[] args) throws IOException {
		DbUtil.connect();
		
//		Map<String, Object> task = new HashMap<String, Object>();
//		task.put("url", "http://m.58.com/bj/sale.shtml?from=home_sale");
//		task.put("workbeach", "58");
//		task.put("method", "get");
//		task.put("charset", "utf8");
//		task.put("dataTarget", "URL");
//		task.put("processor", "TypeProcessor");
//		Map<String, String> header = new HashMap<String, String>();
//		header.put("User-Agent", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16");
//		task.put("header", header);
//		task.put("state", "0");
//		task.put("cookie", Collections.EMPTY_MAP);
//		task.put("data", Collections.EMPTY_MAP);
//		task.put("root", true);
//		DBCollection coll = DbUtil.getcoll("task");
//		coll.insert(new BasicDBObject(task));
		
		
		
		String taskid = "53e85eb2c98acbcee4d65c57";
		Map<String, Object> rule = new HashMap<String, Object>();
		rule.put("name", "");
		rule.put("taskid", taskid);
		rule.put("pid", "0");
		rule.put("cid", "1");
		Map<String, String> exp = new HashMap<String, String>();
		exp.put("selector", "a#contact_phone");
		exp.put("attr", "href");
		rule.put("expression", exp);
//		rule.put("pageRule", "pn\\d");
//		rule.put("pageSize", 10);
		
		DBCollection coll = DbUtil.getcoll("rule");
		coll.insert(new BasicDBObject(rule));
		
		
	}

}
